package org.example.util;

import cn.hutool.core.text.csv.CsvReadConfig;
import cn.hutool.core.text.csv.CsvReader;

import java.io.File;
import java.io.FileNotFoundException;
import java.nio.charset.Charset;

public class FaqMain {
    public static void main(String[] args)throws FileNotFoundException {
        String url="https://oss-jxhapp.oss-cn-shenzhen.aliyuncs.com/jxh-prdfile/a38a85e0fe2444e2b10fb3ce8d8a3c82.txt?Expires=1700074550&OSSAccessKeyId=LTAI5tH2qGEMncmBLQY4xTbh&Signature=p3E%2FJW%2FR9I0NgtYybi3zUU8YDqw%3D&x-oss-traffic-limit=819200";
        //HttpUtil.downloadFile(url,"C:\\Users\\admin\\Desktop\\faq\\FAQ(1).txt");
        //String read = IoUtil.read(new FileInputStream(new File("C:\\Users\\admin\\Desktop\\faq\\FAQ(1).txt")),"utf8");
        //System.out.println(read.length());
        readcsv();
    }

    public static void readcsv(){
        String f="C:\\Users\\admin\\Desktop\\faq\\faq_csv.csv";
        String javaEncode = EncodingDetect.getJavaEncode(f);
        File hutoolCsv = new File(f);
        CsvReadConfig csvReadConfig = new CsvReadConfig();

        CsvReader reader = new CsvReader(hutoolCsv, Charset.forName(javaEncode),new CsvReadConfig());
        reader.setContainsHeader(true);
        reader.stream().forEach(csvRow -> {
            System.out.println(csvRow.toString());
        });
    }
}
